package gui.tournamentOptions;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.LayoutStyle;
import javax.swing.WindowConstants;

import core.CustomIcons;
import core.GuiComponentLabels;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class TournamentOptions extends javax.swing.JFrame {
	private JPanel tournamentTypeContainer;
	private JScrollPane jScrollPane1;
	private JButton removeRoundButton;
	private JButton addRoundButton;
	private JButton closeButton;
	private JButton saveButton;
	private JCheckBox allBowCathegoriesCheckBox;
	private JCheckBox allAgeClassesCheckBox;
	private JTable distancesTable;
	private JCheckBox allGendersCheckBox;
	private JComboBox genderDropDown;
	private JPanel genderContainer;
	private JComboBox ageClassDropDown;
	private JPanel ageClassContainer;
	private JComboBox bowCathegoryDropDown;
	private JPanel bowCathegoryContainer;
	private JCheckBox allTournamentsCheckBox;
	private JComboBox tournamentTypeDropDown;
	private final TournamentOptionsWindowController controller;
	private static TournamentOptions instance;
	private final TournamentOptionsActionListener actionListener;

	private TournamentOptions() {
		super();
		this.setIconImage(CustomIcons.iconImage);
		this.controller = new TournamentOptionsWindowController();
		this.actionListener = new TournamentOptionsActionListener();
		this.initGUI();

	}

	public static TournamentOptions getInstance() {
		if (instance == null) {
			instance = new TournamentOptions();
		}
		return instance;
	}

	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout(this.getContentPane());
			this.getContentPane().setLayout(thisLayout);
			this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle(GuiComponentLabels.DISTANCES);
			{
				this.tournamentTypeContainer = new JPanel();
				GroupLayout tournamentTypeContainerLayout = new GroupLayout(this.tournamentTypeContainer);
				this.tournamentTypeContainer.setLayout(tournamentTypeContainerLayout);
				this.tournamentTypeContainer.setBorder(BorderFactory.createTitledBorder(GuiComponentLabels.TOURNAMENT_TYPE));
				{
					ComboBoxModel tournamentTypeDropDownModel = new DefaultComboBoxModel(new String [] { "Item One", "Item Two" });
					this.tournamentTypeDropDown = new JComboBox();
					this.tournamentTypeDropDown.setModel(tournamentTypeDropDownModel);
					this.tournamentTypeDropDown.addActionListener(this.actionListener);
				}
				{
					this.allTournamentsCheckBox = new JCheckBox();
					this.allTournamentsCheckBox.setText("alle");
					this.allTournamentsCheckBox.addActionListener(this.actionListener);
				}
				tournamentTypeContainerLayout.setHorizontalGroup(tournamentTypeContainerLayout.createSequentialGroup().addContainerGap()
						.addComponent(this.tournamentTypeDropDown, 0, 158, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 1, GroupLayout.PREFERRED_SIZE)
						.addComponent(this.allTournamentsCheckBox, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE).addContainerGap());
				tournamentTypeContainerLayout.setVerticalGroup(tournamentTypeContainerLayout
						.createSequentialGroup()
						.addContainerGap(21, 21)
						.addGroup(
								tournamentTypeContainerLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
										.addComponent(this.tournamentTypeDropDown, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
										.addComponent(this.allTournamentsCheckBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
						.addContainerGap());
			}
			{
				this.bowCathegoryContainer = new JPanel();
				GroupLayout jPanel1Layout = new GroupLayout(this.bowCathegoryContainer);
				this.bowCathegoryContainer.setBorder(BorderFactory.createTitledBorder(GuiComponentLabels.BOW_CATHEGORY));
				this.bowCathegoryContainer.setLayout(jPanel1Layout);
				{
					ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String [] { "Item One", "Item Two" });
					this.bowCathegoryDropDown = new JComboBox();
					this.bowCathegoryDropDown.setModel(jComboBox1Model);
					this.bowCathegoryDropDown.addActionListener(this.actionListener);
				}
				{
					this.allBowCathegoriesCheckBox = new JCheckBox();
					this.allBowCathegoriesCheckBox.setText("alle");
					this.allBowCathegoriesCheckBox.addActionListener(this.actionListener);
				}
				jPanel1Layout.setVerticalGroup(jPanel1Layout
						.createSequentialGroup()
						.addContainerGap(21, 21)
						.addGroup(
								jPanel1Layout
										.createParallelGroup(GroupLayout.Alignment.BASELINE)
										.addComponent(this.bowCathegoryDropDown, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
										.addComponent(this.allBowCathegoriesCheckBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
												GroupLayout.PREFERRED_SIZE)).addContainerGap());
				jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(this.bowCathegoryDropDown, 0, 158, Short.MAX_VALUE)
						.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 1, GroupLayout.PREFERRED_SIZE)
						.addComponent(this.allBowCathegoriesCheckBox, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE).addContainerGap());
			}
			{
				this.ageClassContainer = new JPanel();
				GroupLayout jPanel1Layout1 = new GroupLayout(this.ageClassContainer);
				this.ageClassContainer.setBorder(BorderFactory.createTitledBorder(GuiComponentLabels.AGE_CLASS));
				this.ageClassContainer.setLayout(jPanel1Layout1);
				{
					ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String [] { "Item One", "Item Two" });
					this.ageClassDropDown = new JComboBox();
					this.ageClassDropDown.setModel(jComboBox1Model);
					this.ageClassDropDown.addActionListener(this.actionListener);
				}
				{
					this.allAgeClassesCheckBox = new JCheckBox();
					this.allAgeClassesCheckBox.setText("alle");
					this.allAgeClassesCheckBox.addActionListener(this.actionListener);
				}
				jPanel1Layout1.setVerticalGroup(jPanel1Layout1
						.createSequentialGroup()
						.addContainerGap(21, 21)
						.addGroup(
								jPanel1Layout1.createParallelGroup(GroupLayout.Alignment.BASELINE)
										.addComponent(this.ageClassDropDown, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
										.addComponent(this.allAgeClassesCheckBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
						.addContainerGap());
				jPanel1Layout1.setHorizontalGroup(jPanel1Layout1.createSequentialGroup().addContainerGap().addComponent(this.ageClassDropDown, 0, 158, Short.MAX_VALUE)
						.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 1, GroupLayout.PREFERRED_SIZE)
						.addComponent(this.allAgeClassesCheckBox, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE).addContainerGap());
			}
			{
				this.genderContainer = new JPanel();
				GroupLayout jPanel1Layout2 = new GroupLayout(this.genderContainer);
				this.genderContainer.setBorder(BorderFactory.createTitledBorder(GuiComponentLabels.GENDER));
				this.genderContainer.setLayout(jPanel1Layout2);
				{
					ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String [] { "Item One", "Item Two" });
					this.genderDropDown = new JComboBox();
					this.genderDropDown.setModel(jComboBox1Model);
					this.genderDropDown.addActionListener(this.actionListener);
				}
				{
					this.allGendersCheckBox = new JCheckBox();
					this.allGendersCheckBox.setText("alle");
					this.allGendersCheckBox.addActionListener(this.actionListener);
				}
				jPanel1Layout2.setVerticalGroup(jPanel1Layout2
						.createSequentialGroup()
						.addContainerGap(21, 21)
						.addGroup(
								jPanel1Layout2.createParallelGroup(GroupLayout.Alignment.BASELINE)
										.addComponent(this.genderDropDown, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
										.addComponent(this.allGendersCheckBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
						.addContainerGap());
				jPanel1Layout2.setHorizontalGroup(jPanel1Layout2.createSequentialGroup().addContainerGap().addComponent(this.genderDropDown, 0, 158, Short.MAX_VALUE)
						.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 1, GroupLayout.PREFERRED_SIZE)
						.addComponent(this.allGendersCheckBox, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE).addContainerGap());
			}
			{
				this.jScrollPane1 = new JScrollPane();
				{
					this.distancesTable = new JTable();
					this.jScrollPane1.setViewportView(this.distancesTable);
					this.distancesTable.setDefaultRenderer(Object.class, new DistancesTableModelRenderer());
				}
			}
			{
				this.saveButton = new JButton();
				this.saveButton.setText(GuiComponentLabels.SAVE_BUTTON);
				this.saveButton.setIcon(CustomIcons.save);
				this.saveButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						try {
							TournamentOptions.this.controller.saveAction();
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
				});
			}
			{
				this.addRoundButton = new JButton();
				this.addRoundButton.setText(GuiComponentLabels.ADD_ROUND_BUTTON);
				this.addRoundButton.setIcon(CustomIcons.add);
				this.addRoundButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						TournamentOptions.this.controller.addRound();
					}
				});
			}
			{
				this.removeRoundButton = new JButton();
				this.removeRoundButton.setText(GuiComponentLabels.DELETE_ROUND_BUTTON);
				this.removeRoundButton.setIcon(CustomIcons.remove);
				this.removeRoundButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						TournamentOptions.this.controller.removeRound();
					}
				});
			}
			{
				this.closeButton = new JButton();
				this.closeButton.setText(GuiComponentLabels.CLOSE_BUTTON);
				this.closeButton.setIcon(CustomIcons.exit);
				this.closeButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						TournamentOptions.this.controller.close();
					}
				});
			}
			thisLayout.setVerticalGroup(thisLayout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
							thisLayout
									.createParallelGroup()
									.addGroup(
											GroupLayout.Alignment.LEADING,
											thisLayout.createSequentialGroup().addComponent(this.tournamentTypeContainer, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
													.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
													.addComponent(this.bowCathegoryContainer, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)
													.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
													.addComponent(this.ageClassContainer, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)
													.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
													.addComponent(this.genderContainer, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE))
									.addComponent(this.jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 307, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.addRoundButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.saveButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.closeButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.removeRoundButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addContainerGap());
			thisLayout.setHorizontalGroup(thisLayout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
							thisLayout.createParallelGroup().addComponent(this.removeRoundButton, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.addRoundButton, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.tournamentTypeContainer, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.bowCathegoryContainer, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.ageClassContainer, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.genderContainer, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(
							thisLayout
									.createParallelGroup()
									.addComponent(this.closeButton, GroupLayout.Alignment.LEADING, 0, 165, Short.MAX_VALUE)
									.addComponent(this.saveButton, GroupLayout.Alignment.LEADING, 0, 165, Short.MAX_VALUE)
									.addGroup(
											thisLayout.createSequentialGroup().addComponent(this.jScrollPane1, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE)
													.addGap(0, 0, Short.MAX_VALUE))).addContainerGap());
			this.pack();
			this.setSize(457, 427);
		} catch (Exception e) {
			// add your error handling code here
			e.printStackTrace();
		}
	}

	public JScrollPane getjScrollPane1() {
		return this.jScrollPane1;
	}

	public JButton getRemoveRoundButton() {
		return this.removeRoundButton;
	}

	public JButton getAddRoundButton() {
		return this.addRoundButton;
	}

	public JButton getCloseButton() {
		return this.closeButton;
	}

	public JButton getSaveButton() {
		return this.saveButton;
	}

	public JCheckBox getAllBowCathegoriesCheckBox() {
		return this.allBowCathegoriesCheckBox;
	}

	public JCheckBox getAllAgeClassesCheckBox() {
		return this.allAgeClassesCheckBox;
	}

	public JTable getDistancesTable() {
		return this.distancesTable;
	}

	public JCheckBox getAllGendersCheckBox() {
		return this.allGendersCheckBox;
	}

	public JComboBox getGenderDropDown() {
		return this.genderDropDown;
	}

	public JComboBox getAgeClassDropDown() {
		return this.ageClassDropDown;
	}

	public JComboBox getBowCathegoryDropDown() {
		return this.bowCathegoryDropDown;
	}

	public JCheckBox getAllTournamentsCheckBox() {
		return this.allTournamentsCheckBox;
	}

	public JComboBox getTournamentTypeDropDown() {
		return this.tournamentTypeDropDown;
	}

	public TournamentOptionsWindowController getController() {
		return this.controller;
	}

}
